#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
int GetNumberOfK(int* nums, int numsLen, int k) 
{
    int left = 0;
    int right = numsLen - 1;
    int mid = 0;
    int count = 0;
    int flag = 0;
    if (numsLen >= 2) 
    {
        while (left < right) 
        {
            mid = (left + right) / 2;
            if (nums[mid] > k) 
            {
                right = mid - 1;
            }
            else if (nums[mid] < k) 
            {
                left = mid + 1;
            }
            else 
            {
                flag = 1;
                count++;
                break;
            }
        }
    }
    else if (numsLen == 1) 
    {
        return nums[0] == k;
    }
    else 
    {
        return 0;
    }
    if (flag) 
    {
        int temp = mid;
        while (nums[--mid] == k) 
        {
            count++;
        }
        mid = temp;
        while (nums[++mid] == k) 
        {
            count++;
        }
    }
    return count;
}

int main()
{
    int n = 0;
    int k = 0;
    scanf("%d", &n);
    int* nums = (int*)malloc(sizeof(int) * n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &nums[i]);
    }
    scanf("%d", &k);
    int ret = GetNumberOfK(nums, n, k);
    printf("%d", ret);
    return 0;
}